//
//  CancleOrderVC.m
//  MyProject
//
//  Created by jiaming yan on 2018/3/24.
//  Copyright © 2018年 yanjiaming. All rights reserved.
//

#import "CancleOrderVC.h"
#import "IQTextView.h"

@interface CancleOrderVC ()

@property (weak, nonatomic) IBOutlet IQTextView *desTextView;

@property (weak, nonatomic) IBOutlet UIButton *button1;
@property (weak, nonatomic) IBOutlet UIButton *button2;
@property (weak, nonatomic) IBOutlet UIButton *button3;
@property (weak, nonatomic) IBOutlet UIButton *button4;

@property (weak, nonatomic) IBOutlet UIImageView *imageView1;
@property (weak, nonatomic) IBOutlet UIImageView *imageView2;
@property (weak, nonatomic) IBOutlet UIImageView *imageView3;
@property (weak, nonatomic) IBOutlet UIImageView *imageView4;
@property(nonatomic,copy) NSString *reason;
@end

@implementation CancleOrderVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title = @"请选择取消原因";
    self.desTextView.placeholder = @"请描述问题详情，以便对方了解实际情况。";
    self.reason = @"最近安排有变，希望下次合作";
    self.desTextView.text = @"";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)typeButtonClick:(UIButton *)sender {
    if (sender == self.button1) {
        self.imageView1.hidden = NO;
        self.imageView2.hidden = YES;
        self.imageView3.hidden = YES;
        self.imageView4.hidden = YES;
        self.reason = @"最近安排有变，希望下次合作";
    }else if (sender == self.button2) {
        self.imageView1.hidden = YES;
        self.imageView2.hidden = NO;
        self.imageView3.hidden = YES;
        self.imageView4.hidden = YES;
        self.reason = @"不小心点错，多有打扰抱歉。";
    }else if (sender == self.button3) {
        self.imageView1.hidden = YES;
        self.imageView2.hidden = YES;
        self.imageView3.hidden = NO;
        self.imageView4.hidden = YES;
        self.reason = @"谢谢您我的问题已经解决了。";
    }else if (sender == self.button4) {
        self.imageView1.hidden = YES;
        self.imageView2.hidden = YES;
        self.imageView3.hidden = YES;
        self.imageView4.hidden = NO;
        self.reason = @"其它原因";
    }
}

- (IBAction)submitClick:(id)sender {
    
    NSString *url = @"";
    NSString *key = @"";
    if (self.type == 0) {
        /**保过*/
        url = @"assurePass/cancel";
        key = @"assurePassId";
    }else if (self.type == 1){
        /**解密*/
        url = @"decrypt/cancel";
        key = @"decryptId";
    }
    __weak typeof(self) weakSelf = self;
    [self showProgressWithView:self.view animated:YES];
    [YJMSendRequest postDataWithParameters:@{key:self.relatedId,@"reason":self.reason,@"remark":self.desTextView.text} url:url result:^(NSDictionary *result, NSError *error) {
        result = [CommonUtils decryptDicWithResult:result];
        [weakSelf hideProgress:self.view animated:YES];
        if([result[@"result"] integerValue] == 1)
        {
            
            [self.navigationController popToRootViewControllerAnimated:YES];
            ALERT_VIEW(@"订单取消完成");
            
        }else{
            
            
            [CommonUtils showToast:[result objectForKey:@"msg"]];
        }
        
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
